package org.zecontech.extraplus.datagen.loot;

import net.minecraft.core.HolderLookup;
import net.minecraft.core.WritableRegistry;
import net.minecraft.data.PackOutput;
import net.minecraft.data.loot.LootTableProvider;
import net.minecraft.util.ProblemReporter;
import net.minecraft.world.level.storage.loot.LootTable;
import net.minecraft.world.level.storage.loot.ValidationContext;
import net.minecraft.world.level.storage.loot.parameters.LootContextParamSets;

import java.util.List;
import java.util.Set;
import java.util.concurrent.CompletableFuture;

/**
 * 模组战利品表提供者
 */
public class ModLootTableProvider extends LootTableProvider {

    public ModLootTableProvider(PackOutput output, CompletableFuture<HolderLookup.Provider> registries) {
        super(output, Set.of(), subProviderEntries(), registries);
    }

    /**
     * 战利品表
     * @return 战利品表
     */
    static List<SubProviderEntry> subProviderEntries() {
        return List.of(
                new SubProviderEntry(ModEntityLoot::new, LootContextParamSets.ENTITY),
                new SubProviderEntry(ModBlockLoot::new, LootContextParamSets.BLOCK)
        );
    }

    /**
     * 判断战利品是否有效
     * @param writableregistry 可写注册
     * @param validationcontext 检测内容
     * @param problemreporter$collector 问题报告
     */
    @Override
    protected void validate(WritableRegistry<LootTable> writableregistry, ValidationContext validationcontext, ProblemReporter.Collector problemreporter$collector) {
        writableregistry.forEach(lootTable -> lootTable.validate(validationcontext));
    }
}